'use strict'
let actions = {}
// 变量中心
actions.setPageType = function ({commit}, abusi) {
  commit('SetPageType', abusi)
}
actions.setView1stMounted = function ({commit}, abusi) {
  commit('setView1stMounted', abusi)
}

/**
 * 获取数据-费用报销-业务信息-起草
 * @param store
 * @param paramObj
 */
actions.getDataSscReimburseByUserId = function (store, paramObj) {
  console.log('-------userId=====', store.state.hsInput.creator.userId)
  store.state.apiloading++
  paramObj.me.httpBpm({
    inputParameter: JSON.stringify({
      'tsId': store.state.hsInput.ts_piid,
      'userId': store.state.hsInput.creator.userId,
      'lang': store.state.lang,
      'ts_piid': store.state.hsInput.ts_piid
    }),
    'apiName': 'PREXPR@AJAX_Reim_001_Draft_Open',
    async: paramObj.async
  }, data => {
    if (data.returnCode === '000000') {
      let resObj = JSON.parse(data.jsonResult)
      resObj && store.commit('SetDataSscReimburseWhBtReimburse', resObj)
      // BB
      let bbArr = []
      try {
        bbArr = JSON.parse(data.bbJsonResult)
      } catch (e) {
        console.log('bb arr jsonparse failed---')
        bbArr = []
      }
      let arr = []
      if (bbArr && bbArr.length > 0) {
        for (let i in bbArr) {
          arr[i] = {
            name: bbArr[i]['value'],
            value: bbArr[i]['relationkey']
          }
        }
      }
      store.state.ssc.reimburse.bbOptions = arr
      paramObj.succfunc && paramObj.succfunc()
    } else {
      paramObj.me.alert(paramObj.me.getResource('alert.unknown.error') + ':getDataSscReimburseByUserId')
    }
    store.state.apiloading--
  }, (data, e) => {
    store.state.apiloading--
  })
}
/**
 * 获取数据-费用报销-主表信息
 * @param store
 * @param paramObj
 */
actions.getDataSscReimburseWhBtReimburse = function (store, paramObj) {
  store.state.apiloading++
  paramObj.me.httpBpmGetBz({
    'tsId': paramObj.me.tsId,
    'tableName': 'WH_BT_REIMBURSE',
    'dictFields': paramObj.me.dictFields,
    'page_LineNbr': 10,
    'begin_line': 0,
    'countFlag': 1
  }, (data, totalNbr) => {
    if (data && data.length > 0) {
      let whBtReimburse = data[0]
      paramObj.me.costshareActtotalsum = whBtReimburse.costshareActtotalsum
      store.commit('SetDataSscReimburseWhBtReimburse', whBtReimburse)
    } else {
      store.commit('SetDataSscReimburseWhBtReimburse', {})
    }
    store.state.apiloading--
  }, (data, e) => {
    // paramObj.me.alert('获取出租费数据失败')
    paramObj.me.alert(paramObj.me.getResource('alert.unknown.error') + ':getDataSscReimburseWhBtReimburse')
    store.state.apiloading--
  })
}
/**
 * 获取数据-费用报销-制证信息
 * @param store
 * @param paramObj
 */
actions.getDataSscReimburseWhBtReimburseRcmSub = function (store, paramObj) {
  store.state.apiloading++
  paramObj.me.httpBpmGetBz({
    'tsId': paramObj.me.tsId,
    'tableName': 'WH_BT_REIMBURSE_RCM_SUB',
    'dictFields': paramObj.me.dictFields,
    'page_LineNbr': 10,
    'begin_line': 0,
    'countFlag': 1
  }, (data, totalNbr) => {
    if (data && data.length > 0) {
      let whBtReimburseRcmSub = data[0]
      store.commit('SetDataSscReimburseWhBtReimburseRcmSub', whBtReimburseRcmSub)
    } else {
      store.commit('SetDataSscReimburseWhBtReimburseRcmSub', {})
    }
    store.state.apiloading--
  }, (data, e) => {
    // paramObj.me.alert('获取出租费数据失败')
    paramObj.me.alert(paramObj.me.getResource('alert.unknown.error') + ':getDataSscReimburseWhBtReimburseRcmSub')
    store.state.apiloading--
  })
}
/**
 * 获取费用报销订单信息
 * @param store
 * @param paramObj
 */
actions.getDataFromTableDdSub = function (store, paramObj) {
  console.log('store', store)
  store.state.apiloading++
  paramObj.me.httpBpmGetBz({
    'tsId': store.state.tsId,
    'tableName': 'WH_BT_REIMBURSE_DD_SUB',
    'dictFields': paramObj.me.dictFields,
    'page_LineNbr': store.state.gridPageInfo.ssc.reimburse.whBtReimburseDdSub.count,
    'begin_line': store.state.gridPageInfo.ssc.reimburse.whBtReimburseDdSub.start,
    'countFlag': 1,
    async: paramObj.async
  }, (data, totalNbr) => {
    let totalNb = parseInt(totalNbr + '')
    if (totalNb > 0 && totalNb > store.state.gridPageInfo.ssc.reimburse.whBtReimburseDdSub.max) {
      store.commit('upGridPageInfoWithPathAndValue', {
        path: 'whBtReimburseDdSub',
        name: 'max',
        value: totalNb
      })
    }
    console.log('SetDataSscReimburseWhBtReimburseDdSub', data, totalNbr)
    store.commit('SetDataSscReimburseWhBtReimburseDdSub', data)
    store.state.apiloading--
  }, (data, e) => {
    // paramObj.me.alert('获取费用报销订单信息失败')
    paramObj.me.alert(paramObj.me.getResource('alert.unknown.error') + ':getDataFromTableDdSub')
    store.state.apiloading--
  })
}

/**
 * 获取费用报销成本分摊表信息
 * @param store
 * @param paramObj
 */
actions.getDataFromTableCostshare = function (store, paramObj) {
  store.state.apiloading++
  paramObj.me.httpBpmGetBz({
    'tsId': store.state.tsId,
    'tableName': 'WH_BT_REIMBURSE_COSTSHARE',
    'dictFields': paramObj.me.dictFields,
    'page_LineNbr': store.state.gridPageInfo.ssc.reimburse.whBtReimburseCostshare.count,
    'begin_line': store.state.gridPageInfo.ssc.reimburse.whBtReimburseCostshare.start,
    'countFlag': 1,
    async: paramObj.async
  }, (data, totalNbr) => {
    let totalNb = parseInt(totalNbr + '')
    if (totalNb > 0 && totalNb > store.state.gridPageInfo.ssc.reimburse.whBtReimburseCostshare.max) {
      store.commit('upGridPageInfoWithPathAndValue', {
        path: 'whBtReimburseCostshare',
        name: 'max',
        value: totalNb
      })
    }
    console.log('getDataFromTableCostshare data', data)
    // 获取可用预算

    if (store.state.pageType === store.state.pageTypeEnum.approve && data && data.length > 0) {
      let params = {}
      let params2 = {}
      params.lang = store.state.lang
      params.currentPage = ''
      params.lineNumber = ''
      params.field1 = ''
      params.field2 = ''
      params.Data = []
      for (var i = 0; i < data.length; i++) {
        params.Data[i] = {}
        params.Data[i].costCenterCode = data[i].costcentercode
        params.Data[i].internalOrderCode = data[i].internalordercode
        params.Data[i].subjectCode = data[i].subjectcode
        params.Data[i].field3 = ''
        params.Data[i].field4 = ''
      }
      console.log('getDataFromTableCostshare params->', params)
      params2.DT_321_BPM_AvailableBudgetQuery = params
      params2.apiName = 'PREXPR@AJAX_321_AvailableBudgetQuery'
      console.log('getDataFromTableCostshare params2->', params2)
      store.state.apiloading++
      paramObj.me.httpBpm(params2, data2 => {
        console.log('getDataFromTableCostshare data2->', data2)
        if (data2.DT_321_BPM_AvailableBudgetQuery_Resp.executeStatus === 'S') {
          console.log('store.state.ssc.reimburse.whBtReimburse.rate->', store.state.ssc.reimburse.whBtReimburse.rate)
          let rate = 1
          if (store.state.ssc.reimburse.whBtReimburse.rate && store.state.ssc.reimburse.whBtReimburse.rate > 0) {
            rate = store.state.ssc.reimburse.whBtReimburse.rate
          }
          let listLen = data2.DT_321_BPM_AvailableBudgetQuery_Resp.Data.items.length
          console.log('getDataFromTableCostshare data before->', data)
          if (listLen > 0) {
            for (var i = 0; i < listLen; i++) {
              data[i].costcenterbudget = (data2.DT_321_BPM_AvailableBudgetQuery_Resp.Data.items[i].availableAmount) * rate
            }
          } else {
            // paramObj.me.alert('业务失败,未获取到订单数据')
            paramObj.me.alert(paramObj.me.getResource('alert.unknown.error') + ':getDataFromTableCostshare')
          }
          console.log('getDataFromTableCostshare data after->', data)
          store.state.apiloading--
        } else {
          // paramObj.me.alert('业务失败')
          paramObj.me.alert(paramObj.me.getResource('alert.unknown.error') + ':getDataFromTableCostshare')
          store.state.apiloading--
        }
      }, (data, e) => {
      })
    }
    //
    console.log('SetDataSscReimburseWhBtReimburseCostshare', data, totalNbr)
    store.commit('SetDataSscReimburseWhBtReimburseCostshare', data)
    store.state.apiloading--
  }, (data, e) => {
    // paramObj.me.alert('获取费用报销成本分摊表信息失败')
    paramObj.me.alert(paramObj.me.getResource('alert.unknown.error') + ':getDataFromTableCostshare')
    store.state.apiloading--
  })
}

/**
 * 获取差率补贴表数据
 * @param store
 * @param paramObj
 */
actions.getDataFromTableTravelSubsidyDetails = function (store, paramObj) {
  store.state.apiloading++
  paramObj.me.httpBpmGetBz({
    'tsId': store.state.tsId,
    'tableName': 'WH_BT_TRAVELSUBSIDYDETAILS',
    'dictFields': paramObj.me.dictFields,
    'page_LineNbr': store.state.gridPageInfo.ssc.reimburse.whBtTravelSubsidyDetails.count,
    'begin_line': store.state.gridPageInfo.ssc.reimburse.whBtTravelSubsidyDetails.start,
    'countFlag': 1,
    async: paramObj.async
  }, (data, totalNbr) => {
    let totalNb = parseInt(totalNbr + '')
    if (totalNb > 0 && totalNb > store.state.gridPageInfo.ssc.reimburse.whBtTravelSubsidyDetails.max) {
      store.commit('upGridPageInfoWithPathAndValue', {
        path: 'whBtTravelSubsidyDetails',
        name: 'max',
        value: totalNb
      })
    }
    console.log('SetDataSscReimburseWhBtTravelSubsidyDetails', data, totalNbr)
    store.commit('SetDataSscReimburseWhBtTravelSubsidyDetails', data)
    store.state.apiloading--
  }, (data, e) => {
    // paramObj.me.alert('获取差率补贴表数据失败')
    paramObj.me.alert(paramObj.me.getResource('alert.unknown.error') + ':getDataFromTableTravelSubsidyDetails')
    store.state.apiloading--
  })
}
/**
 * 获取出租表数据
 * @param store
 * @param paramObj
 */
actions.getDataFromTableTransportationDetails = function (store, paramObj) {
  store.state.apiloading++
  paramObj.me.httpBpmGetBz({
    'tsId': store.state.tsId,
    'tableName': 'WH_BT_TRANSPORTATIONDETAILS',
    'dictFields': paramObj.me.dictFields,
    'page_LineNbr': store.state.gridPageInfo.ssc.reimburse.whBtTransportationDetails.count,
    'begin_line': store.state.gridPageInfo.ssc.reimburse.whBtTransportationDetails.start,
    'countFlag': 1,
    async: paramObj.async
  }, (data, totalNbr) => {
    let totalNb = parseInt(totalNbr + '')
    if (totalNb > 0 && totalNb > store.state.gridPageInfo.ssc.reimburse.whBtTransportationDetails.max) {
      store.commit('upGridPageInfoWithPathAndValue', {
        path: 'whBtTransportationDetails',
        name: 'max',
        value: totalNb
      })
    }
    console.log('SetDataSscReimburseWhBtTransportationDetails', data, totalNbr)
    store.commit('SetDataSscReimburseWhBtTransportationDetails', data)
    store.state.apiloading--
  }, (data, e) => {
    // paramObj.me.alert('获取出租表数据失败')
    paramObj.me.alert(paramObj.me.getResource('alert.unknown.error') + ':getDataFromTableTransportationDetails')
    store.state.apiloading--
  })
}
/**
 * 获取交通费表数据
 * @param store
 * @param paramObj
 */
actions.getDataFromTableFareDetails = function (store, paramObj) {
  store.state.apiloading++
  paramObj.me.httpBpmGetBz({
    'tsId': store.state.tsId,
    'tableName': 'WH_BT_FAREDETAILS',
    'dictFields': paramObj.me.dictFields,
    'page_LineNbr': store.state.gridPageInfo.ssc.reimburse.whBtFareDetails.count,
    'begin_line': store.state.gridPageInfo.ssc.reimburse.whBtFareDetails.start,
    'countFlag': 1,
    async: paramObj.async
  }, (data, totalNbr) => {
    let totalNb = parseInt(totalNbr + '')
    if (totalNb > 0 && totalNb > store.state.gridPageInfo.ssc.reimburse.whBtFareDetails.max) {
      store.commit('upGridPageInfoWithPathAndValue', {
        path: 'whBtFareDetails',
        name: 'max',
        value: totalNb
      })
    }
    console.log('SetDataSscReimburseWhBtFareDetails', data, totalNbr)
    store.commit('SetDataSscReimburseWhBtFareDetails', data)
    store.state.apiloading--
  }, (data, e) => {
    // paramObj.me.alert('获取交通费表数据失败')
    paramObj.me.alert(paramObj.me.getResource('alert.unknown.error') + ':getDataFromTableFareDetails')
    store.state.apiloading--
  })
}
/**
 * 获取住宿费表数据
 * @param store
 * @param paramObj
 */
actions.getDataFromTableStayDetails = function (store, paramObj) {
  store.state.apiloading++
  paramObj.me.httpBpmGetBz({
    'tsId': store.state.tsId,
    'tableName': 'WH_BT_STAYDETAILS',
    'dictFields': paramObj.me.dictFields,
    'page_LineNbr': store.state.gridPageInfo.ssc.reimburse.whBtStayDetails.count,
    'begin_line': store.state.gridPageInfo.ssc.reimburse.whBtStayDetails.start,
    'countFlag': 1,
    async: paramObj.async
  }, (data, totalNbr) => {
    let totalNb = parseInt(totalNbr + '')
    if (totalNb > 0 && totalNb > store.state.gridPageInfo.ssc.reimburse.whBtStayDetails.max) {
      store.commit('upGridPageInfoWithPathAndValue', {
        path: 'whBtStayDetails',
        name: 'max',
        value: totalNb
      })
    }
    console.log('SetDataSscReimburseWhBtStayDetails', data, totalNbr)
    store.commit('SetDataSscReimburseWhBtStayDetails', data)
    store.state.apiloading--
  }, (data, e) => {
    // paramObj.me.alert('获取住宿费表数据失败')
    paramObj.me.alert(paramObj.me.getResource('alert.unknown.error') + ':getDataFromTableStayDetails')
    store.state.apiloading--
  })
}
/**
 * 获取制证数据
 * @param store
 * @param paramObj
 */
actions.getDataFromAJAX_Reim_005_ApproveFee_Open = function (store, paramObj) {
  store.state.apiloading++
  paramObj.me.httpBpm({
    'tsId': store.state.tsId,
    'apiName': 'PREXPR@AJAX_Reim_005_ApproveFee_Open',
    // 'page_LineNbr': store.state.gridPageInfo.ssc.reimburse.whBtReimburseRcmSub.count,
    // 'begin_line': store.state.gridPageInfo.ssc.reimburse.whBtReimburseRcmSub.start,
    // 'countFlag': 1,
    'async': paramObj.async
  }, data => {
    if (data.returnCode === '000000') {
      store.commit('SetDataSscReimburseWhBtReimburseRcmSub', data.whBtReimburseRcmSub)
      paramObj.me.reloadRechargeMoney()
    } else {
      // paramObj.me.alert('业务失败')
      paramObj.me.alert(paramObj.me.getResource('alert.unknown.error') + ':getDataFromAJAX_Reim_005_ApproveFee_Open')
    }
    store.state.apiloading--
  }, (data, e) => {
    store.state.apiloading--
  })
}

/**
 * 获取制证表明细数据
 * @param store
 * @param paramObj
 */
actions.getDataFromTableRcmDetails = function (store, paramObj) {
  store.state.apiloading++
  paramObj.me.httpBpmGetBz({
    'tsId': store.state.tsId,
    'tableName': 'wh_vbt_reimburse_rcm_details',
    'dictFields': paramObj.me.dictFields,
    'page_LineNbr': store.state.gridPageInfo.ssc.reimburse.whBtReimburseRcmDetail.count,
    'begin_line': store.state.gridPageInfo.ssc.reimburse.whBtReimburseRcmDetail.start,
    'countFlag': 1,
    'async': paramObj.async
  }, (data, totalNbr) => {
    let totalNb = parseInt(totalNbr + '')
    if (totalNb > 0 && totalNb > store.state.gridPageInfo.ssc.reimburse.whBtReimburseRcmDetail.max) {
      store.commit('upGridPageInfoWithPathAndValue', {
        path: 'whBtReimburseRcmDetail',
        name: 'max',
        value: totalNb
      })
    }
    console.log('SetDataSscReimburseWhBtReimburseRcmDetails', data, totalNbr)
    store.commit('SetDataSscReimburseWhBtReimburseRcmDetails', data)
    store.state.apiloading--
  }, (data, e) => {
    // paramObj.me.alert('获取制证明细表数据失败')
    paramObj.me.alert(paramObj.me.getResource('alert.unknown.error') + ':getDataFromTableRcmDetails')
    store.state.apiloading--
  })
}
/**
 * 查询跨公司提报数据
 * @param store
 * @param paramObj
 */
actions.getCrossCompany = function (store, paramObj) {
  let obj = {}
  let params = {}
  let params2 = {}
  obj.isMultiple = false
  obj.flowType = 'SSCV3.ExpenseReimburse'
  // obj.userId = 'gyren'
  obj.userId = store.state.userId
  let searchClause = JSON.stringify(obj)
  params.searchClause = searchClause
  params.begin_line = -1
  params.page_LineNbr = 10
  params.countFlag = 0
  params.returnBoName = ''
  let inputParameter = JSON.stringify(params)
  params2.apiName = 'EBCOMMA@AJAX_RetrieveCrossCompanyData'
  params2.inputParameter = inputParameter
  params2.async = paramObj.async
  store.state.apiloading++
  paramObj.me.httpBpm(params2, data => {
    if (data.returnCode === '000000') {
      let jsonList = JSON.parse(data.jsonResult)
      if (jsonList && jsonList.length > 0) {
        store.commit('SetDataSscReimburseCtCrossCompany', jsonList)
      } else {
        store.state.ssc.reimburse.crossCompanyInfo = []
      }
    } else {
      // paramObj.me.alert('获取公司数据失败')
      paramObj.me.alert(paramObj.me.getResource('alert.unknown.error') + ':getCrossCompany')
    }
    store.state.apiloading--
  }, (data, e) => {
    store.state.apiloading--
  })
}
/**
 * 查询附件个数 TODO
 * @param store
 * @param paramObj
 */
actions.getAttachmentList = function (store, paramObj) {
  let obj = {}
  let params = {}
  let params2 = {}
  obj.tsPiid = store.state.tsId
  let searchClause = JSON.stringify(obj)
  params.searchClause = searchClause
  let inputParameter = JSON.stringify(params)
  params2.apiName = 'EBCOMMA@AJAX_RetrieveAttachList'
  params2.inputParameter = inputParameter
  params2.async = paramObj.async
  store.state.apiloading++
  console.log('attach info', params2)
  paramObj.me.httpBpm(params2, data => {
    console.log('attachment list num error---------', data)
    if (data.returnCode === '000000') {
      let jsonList = JSON.parse(data.jsonResult)
      if (jsonList && jsonList.length > 0) {
        // store.commit('SetDataSscReimburseCtCrossCompany', jsonList)
      } else {
        // store.state.ssc.reimburse.crossCompanyInfo = []
      }
    } else {
      // paramObj.me.alert('获取公司数据失败')
      paramObj.me.alert(paramObj.me.getResource('alert.unknown.error') + ':getAttachmentList')
    }
    store.state.apiloading--
  }, (data, e) => {
    console.log('attachment list num error---------', data)
    store.state.apiloading--
  })
}
/**
 * 查询银行卡号数据
 * @param store
 * @param paramObj
 */
actions.queryStaffBankInfo = function (store, paramObj) {
  let params = {}
  let params2 = {}
  params.searchClause = paramObj.gatherupNumber
  params.lang = 'zh'
  params.begin_line = 0
  params.page_LineNbr = 10
  params.countFlag = 1
  params.returnBoName = ''
  let inputParameter = JSON.stringify(params)
  params2.apiName = 'PREXPR@AJAX_177_StaffBankInfoQuery'
  params2.inputParameter = inputParameter
  params2.async = paramObj.async
  store.state.apiloading++
  paramObj.me.httpBpm(params2, data => {
    if (data.returnCode === '000000') {
      let jsonList = JSON.parse(data.jsonResult)
      if (jsonList && jsonList.length > 0) {
        store.commit('SetDataSscReimburseStaffBankList', jsonList)
      } else {
        store.state.ssc.reimburse.staffBankList = []
      }
    } else {
      // paramObj.me.alert('获取卡号数据失败')
      paramObj.me.alert(paramObj.me.getResource('alert.unknown.error') + ':queryStaffBankInfo')
    }
    store.state.apiloading--
  }, (data, e) => {
    store.state.apiloading--
  })
}
/**
 * 查询币别数据
 * @param store
 * @param paramObj
 */
actions.queryBBOptions = function (store, paramObj) {
  store.state.apiloading++
  paramObj.me.httpBpm({
    inputParameter: JSON.stringify(JSON.stringify({
      'companyCode': paramObj.companyCode,
      'type': 'BB',
      'parentType': '',
      'parentKey': ''
    })),
    'apiName': 'PREXPR@AJAX_RetrieveOptionsBySql',
    'async': paramObj.async
  }, data => {
    let arr = []
    if (data && data.nameValuePairList && data.nameValuePairList.items) {
      arr = data.nameValuePairList.items
    }
    store.state.ssc.reimburse.bbOptions = arr
    store.state.apiloading--
  }, (data, e) => {
    // paramObj.me.alert('获取币别失败')
    paramObj.me.alert(paramObj.me.getResource('alert.unknown.error') + ':queryBBOptions')
    store.state.apiloading--
  })
}
/**
 * 查询组织
 * @param store
 * @param paramObj
 */
actions.loadAllOrgs = function (store, paramObj) {
  store.state.dialogloading++
  paramObj.me.httpBpm({
    inputParameter: JSON.stringify({
      'inUserIds': '',
      'inFilter': '',
      'inOrgUid': '00000001',
      'inIsDisplayAll': '',
      'inRadio': '1',
      'inDisplay': '1',
      'inLang': 'zh'
    }),
    async: paramObj.async,
    'apiName': 'PREXPR@AJAX_LDAP001_loadAllOrgAndRootGroup'
  }, data => {
    if (data.returnCode === '000000') {
      let jsonList = JSON.parse(data.resultData)
      if (jsonList && jsonList.length > 0) {
        store.commit('setLdapArray', jsonList)
      } else {
        store.state.ldap.departmentArray = []
      }
    } else {
      // paramObj.me.alert('获取部门树失败')
      paramObj.me.alert(paramObj.me.getResource('alert.unknown.error') + ':loadAllOrgs')
      store.state.ldap.departmentArray = []
    }
    store.state.dialogloading--
  }, (data, e) => {
    console.log('=======ldap tree data=======', data)
    store.state.dialogloading--
  })
}
/**
 * 通过组织查询用户列表
 * @param store
 * @param paramObj
 */
actions.queryUserListByOrgId = function (store, paramObj) {
  store.state.dialogloading++
  paramObj.me.httpBpm({
    inputParameter: JSON.stringify({
      'inUserIds': '',
      'inOrgUid': paramObj.inOrgUid,
      'inLang': 'zh'
    }),
    'apiName': 'PREXPR@AJAX_LDAP002_QueryUserListByOrgUid'
  }, data => {
    if (data.returnCode === '000000') {
      let jsonList = JSON.parse(data.resultData)
      if (jsonList && jsonList.length > 0) {
        let array = []
        for (let j in jsonList) {
          let item = {
            uid: jsonList[j].uid,
            cn: jsonList[j].wanhuaCn,
            displayname: jsonList[j].orgName,
            employeenumber: jsonList[j].employeeNumber
          }
          array.push(item)
        }
        store.commit('setUserArray', array)
      } else {
        store.state.ldap.userArray = []
      }
    } else {
      // paramObj.me.alert('获取用户列表失败')
      paramObj.me.alert(paramObj.me.getResource('alert.unknown.error') + ':queryUserListByOrgId')
      store.state.ldap.userArray = []
    }
    store.state.dialogloading--
  }, (data, e) => {
    console.log('=======ldap tree data=======', data)
    store.state.dialogloading--
  })
}
/**
 * 查询指定类型流程链接
 * @param store
 * @param paramObj
 */
actions.queryAppListByType = function (store, paramObj) {
  var obj = {
    userId: store.state.userId,
    bpdName: paramObj.bpdName,
    tableName: 'TSV_APPLICATION',
    lang: 'zh',
    sortFields: '',
    dictFields: ''
  }
  if (paramObj.bpdName === 'HRV3.FrgnaMgmt-VisaApply') {
    obj.page_LineNbr = store.state.gridPageInfo.ssc.reimburse.abroadApplyList.count + ''
    obj.begin_line = store.state.gridPageInfo.ssc.reimburse.abroadApplyList.start + ''
    obj.countFlag = 1 + ''
  } else if (paramObj.bpdName === 'HR.StaffTrain') {
    obj.page_LineNbr = store.state.gridPageInfo.ssc.reimburse.trainApplyList.count + ''
    obj.begin_line = store.state.gridPageInfo.ssc.reimburse.trainApplyList.start + ''
    obj.countFlag = 1 + ''
  }
  // obj.bpdName = 'HRV3.FrgnaMgmt-VisaApply'
  // HR.StaffTrain
  store.state.dialogloading++
  paramObj.me.httpBpm({
    inputParameter: JSON.stringify(obj),
    'apiName': 'PREXPR@AJAX_Reim_010_Draft_AppQuery'
  }, data => {
    console.log('get app list....', data)
    if (data.returnCode === '000000') {
      let totalNbr = parseInt(data.totalNbr + '')
      let jsonList = JSON.parse(data.returnJson)
      if (jsonList && jsonList.length > 0) {
        if (paramObj.bpdName === 'HRV3.FrgnaMgmt-VisaApply') {
          console.log('totalNbr', totalNbr, store.state.gridPageInfo.ssc.reimburse.abroadApplyList.max)
          if (totalNbr > 0 && totalNbr > store.state.gridPageInfo.ssc.reimburse.abroadApplyList.max) {
            console.log('into', totalNbr, store.state.gridPageInfo.ssc.reimburse.abroadApplyList.max)
            store.commit('upGridPageInfoWithPathAndValue', {
              path: 'abroadApplyList',
              name: 'max',
              value: totalNbr
            })
          }
          store.commit('updateDataSscReimburse', {
            name: 'abroadApplyTitle',
            value: data.bpdName
          })
          store.commit('updateDataSscReimburse', {
            name: 'abroadApplyList',
            value: jsonList
          })
        } else if (paramObj.bpdName === 'HR.StaffTrain') {
          if (totalNbr > 0 && totalNbr > store.state.gridPageInfo.ssc.reimburse.trainApplyList.max) {
            store.commit('upGridPageInfoWithPathAndValue', {
              path: 'trainApplyList',
              name: 'max',
              value: totalNbr
            })
          }
          store.commit('updateDataSscReimburse', {
            name: 'trainApplyTitle',
            value: data.bpdName
          })
          store.commit('updateDataSscReimburse', {
            name: 'trainApplyList',
            value: jsonList
          })
        }
      } else {
        if (paramObj.bpdName === 'HRV3.FrgnaMgmt-VisaApply') {
          store.commit('updateDataSscReimburse', {
            name: 'abroadApplyTitle',
            value: data.bpdName
          })
          store.state.ssc.reimburse.abroadApplyList = []
        } else if (paramObj.bpdName === 'HR.StaffTrain') {
          store.commit('updateDataSscReimburse', {
            name: 'trainApplyTitle',
            value: data.bpdName
          })
          store.state.ssc.reimburse.trainApplyList = []
        }
      }
    } else {
      // paramObj.me.alert('获取流程列表失败')
      paramObj.me.alert(paramObj.me.getResource('alert.unknown.error') + ':queryAppListByType')
      if (paramObj.bpdName === 'HRV3.FrgnaMgmt-VisaApply') {
        store.state.ssc.reimburse.abroadApplyList = []
      } else if (paramObj.bpdName === 'HR.StaffTrain') {
        store.state.ssc.reimburse.trainApplyList = []
      }
    }
    store.state.dialogloading--
  }, (data, e) => {
    console.log('=======apply error list=======', data)
    store.state.dialogloading--
  })
}
/**
 * 查询用户
 * @param store
 * @param paramObj
 */
actions.queryUserListByKeyword = function (store, paramObj) {
  store.state.dialogloading++
  paramObj.me.httpBpm({
    inputParameter: JSON.stringify({
      'inOrgId': '00000001',
      'inKeywords': paramObj.inKeywords,
      'inAuthUid': '0'
    }),
    'apiName': 'PREXPR@AJAX_LDAP003_QueryKeywordsUserList'
  }, data => {
    if (data.returnCode === '000000') {
      let jsonList = JSON.parse(data.resultData)
      if (jsonList && jsonList.length > 0) {
        let array = []
        for (let j in jsonList) {
          let item = {
            uid: jsonList[j].uid,
            cn: jsonList[j].wanhuaCn,
            displayname: jsonList[j].orgName,
            employeenumber: jsonList[j].employeeNumber
          }
          array.push(item)
        }
        store.commit('setUserArray', array)
      } else {
        store.state.ldap.userArray = []
      }
    } else {
      // paramObj.me.alert('获取用户列表失败')
      paramObj.me.alert(paramObj.me.getResource('alert.unknown.error') + ':queryUserListByKeyword')
      store.state.ldap.userArray = []
    }
    store.state.dialogloading--
  }, (data, e) => {
    console.log('=======ldap tree data=======', data)
    store.state.dialogloading--
  })
}
/**
 * 通过接口查询成本中心数据
 * @param store
 * @param paramObj
 */
actions.queryCostCenter = function (store, paramObj) {
  let obj = {}
  let params = {}
  let params2 = {}
  obj.proposer = store.state.userId
  obj.companyCode = paramObj.companyCode + ''
  obj.costCenterCode = paramObj.costCenterCode
  obj.costCenterName = paramObj.costCenterName
  let searchClause = JSON.stringify(obj)
  params.searchClause = searchClause
  params.begin_line = 0
  params.page_LineNbr = 10
  params.countFlag = 0
  params.returnBoName = ''
  let inputParameter = JSON.stringify(params)
  params2.apiName = 'EBSA@AJAX_172_CostCenterQuery'
  params2.inputParameter = inputParameter
  store.state.apiloading++
  paramObj.me.httpBpm(params2, data => {
    if (data.returnCode === '000000') {
      let jsonList = JSON.parse(data.jsonResult)
      if (data.totalNbr > 0 && jsonList && jsonList.length > 0) {
        store.commit('SetDataSscReimburseCostCenterList', jsonList)
        // console.log('=========', store.reimburse.costCenterList)
      } else {
        store.state.ssc.reimburse.costCenterList = []
      }
    } else {
      // paramObj.me.alert('获取成本中心数据失败')
      paramObj.me.alert(paramObj.me.getResource('alert.unknown.error') + ':queryCostCenter')
    }
    store.state.apiloading--
  }, (data, e) => {
    store.state.apiloading--
  })
}
/**
 * 通过接口查询内部订单数据,用在费用分摊部分。
 * @param store
 * @param paramObj
 */
actions.querySplitInternalOrder = function (store, paramObj) {
  let obj = {}
  let params = {}
  let params2 = {}
  obj.proposer = store.state.userId
  obj.costcenterCode = paramObj.costcenterCode
  obj.companyCode = paramObj.companyCode + ''
  obj.internalOrderName = paramObj.queryInternalOrderName
  obj.internalOrderCode = paramObj.queryInternalOrderCode
  obj.year = ''
  let searchClause = JSON.stringify(obj)
  params.searchClause = searchClause
  params.begin_line = 0
  params.page_LineNbr = 10
  params.countFlag = 1
  params.returnBoName = ''
  let inputParameter = JSON.stringify(params)
  params2.apiName = 'EBSA@AJAX_173_InternalOrderquery'
  params2.inputParameter = inputParameter
  params2.async = paramObj.async
  store.state.dialogloading++
  paramObj.me.httpBpm(params2, data => {
    console.log('get Internal Order', data)
    if (data.returnCode === '000000') {
      let jsonList = JSON.parse(data.jsonResult)
      if (jsonList && jsonList.length > 0) {
        store.commit('SetDataSscReimburseSplitInternalOrderList', jsonList)
      } else {
        store.state.ssc.reimburse.splitInternalOrderList = []
      }
    } else {
      // paramObj.me.alert('获取内部订单数据失败')
      paramObj.me.alert(paramObj.me.getResource('alert.unknown.error') + ':querySplitInternalOrder')
    }
    store.state.dialogloading--
  }, (data, e) => {
    store.state.dialogloading--
  })
}
/**
 * 通过接口查询内部订单数据
 * @param store
 * @param paramObj
 */
actions.queryInternalOrder = function (store, paramObj) {
  let obj = {}
  let params = {}
  let params2 = {}
  obj.proposer = store.state.userId
  obj.costcenterCode = paramObj.costcenterCode
  obj.companyCode = paramObj.companyCode + ''
  obj.internalOrderName = paramObj.queryInternalOrderName
  obj.internalOrderCode = paramObj.queryInternalOrderCode
  obj.year = ''
  let searchClause = JSON.stringify(obj)
  params.searchClause = searchClause
  params.begin_line = 0
  params.page_LineNbr = 10
  params.countFlag = 1
  params.returnBoName = ''
  let inputParameter = JSON.stringify(params)
  params2.apiName = 'EBSA@AJAX_173_InternalOrderquery'
  params2.inputParameter = inputParameter
  params2.async = paramObj.async
  store.state.dialogloading++
  paramObj.me.httpBpm(params2, data => {
    console.log('get Internal Order', data)
    if (data.returnCode === '000000') {
      let jsonList = JSON.parse(data.jsonResult)
      if (jsonList && jsonList.length > 0) {
        store.commit('SetDataSscReimburseInternalOrderList', jsonList)
      } else {
        store.state.ssc.reimburse.internalOrderList = []
      }
    } else {
      // paramObj.me.alert('获取内部订单数据失败')
      paramObj.me.alert(paramObj.me.getResource('alert.unknown.error') + ':queryInternalOrder')
    }
    store.state.dialogloading--
  }, (data, e) => {
    store.state.dialogloading--
  })
}
/**
 * 通过接口查询核算科目数据
 * @param store
 * @param paramObj
 */
actions.queryBudgetSubject = function (store, paramObj) {
  let obj = {}
  let params = {}
  let params2 = {}
  obj.companyCode = paramObj.companyCode + ''
  obj.costingCenterCode = paramObj.costingCenterCode
  obj.inwardOrderCode = paramObj.inwardOrderCode
  obj.budgetSubjectName = paramObj.budgetSubjectName
  obj.budgetSubjectCode = paramObj.budgetSubjectCode
  obj.year = ''
  let searchClause = JSON.stringify(obj)
  params.searchClause = searchClause
  params.begin_line = 0
  params.page_LineNbr = 10
  params.countFlag = 1
  params.returnBoName = ''
  let inputParameter = JSON.stringify(params)
  params2.apiName = 'EBSA@AJAX_175_BudgetSubjectQuery'
  params2.inputParameter = inputParameter
  params2.async = true
  store.state.dialogloading++
  paramObj.me.httpBpm(params2, data => {
    console.log('get budget Order', data)
    if (data.returnCode === '000000') {
      let jsonList = JSON.parse(data.jsonResult)
      if (paramObj.flag === 'split') {
        if (jsonList && jsonList.length > 0) {
          store.state.ssc.reimburse.splitBudgetSubjectList = jsonList
          // store.commit('SetDataSscReimburseBudgetSubjectList', jsonList)
          // console.log('=========', store.reimburse.costCenterList)
        } else {
          store.state.ssc.reimburse.splitBudgetSubjectList = []
        }
      } else if (paramObj.flag === 'pay') {
        if (jsonList && jsonList.length > 0) {
          store.state.ssc.reimburse.budgetSubjectList = jsonList
          // store.commit('SetDataSscReimburseBudgetSubjectList', jsonList)
          // console.log('=========', store.reimburse.costCenterList)
        } else {
          store.state.ssc.reimburse.budgetSubjectList = []
        }
      } else if (paramObj.flag === 'post') {
        if (jsonList && jsonList.length > 0) {
          store.state.ssc.reimburse.postBudgetSubjectList = jsonList
          // store.commit('SetDataSscReimburseBudgetSubjectList', jsonList)
          console.log('===post======', store.state.ssc.reimburse.postBudgetSubjectList)
        } else {
          store.state.ssc.reimburse.postBudgetSubjectList = []
        }
      }
    } else {
      paramObj.me.alert('获取核算科目数据失败')
      paramObj.me.alert(paramObj.me.getResource('alert.unknown.error') + ':queryBudgetSubject')
    }
    store.state.dialogloading--
  }, (data, e) => {
    store.state.dialogloading--
  })
}

/**
 * 制证提交校验-确认是否有用
 * @param store
 * @param paramObj
 */
actions.PREXPR_AJAX_CheckReimburseByTsId = function (store, paramObj) {
  store.state.apiloading++
  paramObj.me.httpBpm({
    'tsId': 'PIID-9e982e74-d555-4a03-8a01-11e7dab76bc5',
    'apiName': 'PREXPR@AJAX_CheckReimburseByTsId'
  }, data => {
    if (data.returnCode === '000000') {
      let resObj = JSON.parse(data.jsonResult)
      store.commit('SetDataSscReimburseWhBtReimburse', resObj)
    } else {
      // paramObj.me.alert('业务失败')
      paramObj.me.alert(paramObj.me.getResource('alert.unknown.error') + ':PREXPR_AJAX_CheckReimburseByTsId')
    }
    store.state.apiloading--
  }, (data, e) => {
    store.state.apiloading--
  })
}
/**
 * 修改表格的选中行码
 * @param store
 * @param paramObj
 */
actions.setGridSelectMid = function (store, paramObj) {
  store.commit('SetGridSelectMid', paramObj)
}

/**
 * 修改表格的选中复选框
 * @param store
 * @param paramObj
 */
actions.setGridCheckboxMids = function (store, paramObj) {
  store.commit('SetGridCheckboxMids', paramObj)
}
/**
 * 删除制证表数据
 * @param store
 * @param paramObj
 */
actions.delTableWh_bt_reimburse_rcm_details = function (store, paramObj) {
  store.state.apiloading++
  paramObj.me.httpBpmDelBz({
    'mids': paramObj.mids,
    'tableName': 'wh_vbt_reimburse_rcm_details'
  }, data => {
    // store.state.gridCheckboxMids['whBtReimburseRcmDetail'].splice(store.state.gridCheckboxMids['whBtReimburseRcmDetail'].indexOf(paramObj.mids), 1)
    actions.getDataFromTableRcmDetails(store, paramObj)
    store.state.apiloading--
  }, (data, e) => {
    // paramObj.me.alert('删除制证明细表数据失败')
    paramObj.me.alert(paramObj.me.getResource('alert.unknown.error') + ':delTableWh_bt_reimburse_rcm_details')
    store.state.apiloading--
  })
}
/**
 * 保存制证表数据
 * @param store
 * @param paramObj
 */
actions.saveTableWh_bt_reimburse_rcm_details = function (store, paramObj) {
  store.state.apiloading++
  paramObj.me.httpBpmSaveBz({
    'data': paramObj.data,
    'keyFields': ['mmid'],
    'tableName': 'wh_vbt_reimburse_rcm_details'
  }, data => {
    actions.getDataFromTableRcmDetails(store, paramObj)
    store.state.apiloading--
  }, (data, e) => {
    // paramObj.me.alert('保存制证明细表数据失败')
    paramObj.me.alert(paramObj.me.getResource('alert.unknown.error') + ':saveTableWh_bt_reimburse_rcm_details')
    store.state.apiloading--
  })
}
/**
 * 保存费用分摊数据
 * @param store
 * @param paramObj
 */
actions.saveTableWh_bt_reimburse_costshare = function (store, paramObj) {
  store.state.apiloading++
  paramObj.me.httpBpmSaveBz({
    'saveFlag': paramObj.saveFlag,
    'data': paramObj.data,
    'keyFields': ['mid'],
    'tableName': 'wh_bt_reimburse_costshare'
  }, data => {
    actions.getDataFromTableCostshare(store, paramObj)
    store.state.apiloading--
  }, (data, e) => {
    // paramObj.me.alert('保存费用分摊表数据失败')
    paramObj.me.alert(paramObj.me.getResource('alert.unknown.error') + ':saveTableWh_bt_reimburse_costshare')
    store.state.apiloading--
  })
}

actions.saveTableWh_bt_reimburse = function (store, paramObj) {
  store.state.apiloading++
  paramObj.me.httpBpmSaveBz({
    'data': paramObj.data,
    'keyFields': ['ts_id'],
    'tableName': 'wh_bt_reimburse'
  }, data => {
    // actions.getDataFromTableReimburse(store, paramObj)
    store.state.apiloading--
  }, (data, e) => {
    // paramObj.me.alert('保存主表数据失败')
    paramObj.me.alert(paramObj.me.getResource('alert.unknown.error') + ':saveTableWh_bt_reimburse')
    store.state.apiloading--
  })
}
/**
 * 审批页面，判断可用预算是否显示,废弃
 * AJAX_Reim_012_Approve_Open
//  */
// actions.checkReimburseApproveTableVisible = function (store, paramObj) {
//   store.state.apiloading++
//   paramObj.me.httpBpm({
//     'userId': paramObj.me.userId,
//     'tsId': paramObj.me.tsId,
//     'apiName': 'PREXPR@AJAX_Reim_012_Approve_Open',
//     'async': paramObj.async
//   }, data => {
//     console.log('checkReimburseApproveTableVisible success', data)
//     if (data.returnCode === '000000') {
//       let viewTableVisible = {}
//       if (data.budgetShow === '0') {
//         viewTableVisible.costCenterBudget = false
//       } else {
//         viewTableVisible.costCenterBudget = true
//       }
//       store.state.viewTableVisible = viewTableVisible
//       console.log('store.state.viewTableVisible', paramObj.me.viewTableVisible)
//     } else {
//       paramObj.me.alert(data.returnMsg)
//     }
//     store.state.apiloading--
//   }, (data, e) => {
//     console.log('checkReimburseApproveTableVisible error')
//     store.state.apiloading--
//   })
// }
/**
 * 只读页面，加载判断费用岗是否显示
 * AJAX_Reim_006_View
 */
actions.checkReimburseViewTableVisible = function (store, paramObj) {
  store.state.apiloading++
  paramObj.me.httpBpm({
    'userId': paramObj.me.userId,
    'tsId': paramObj.me.tsId,
    'apiName': 'PREXPR@AJAX_Reim_006_View_Open',
    'async': true
  }, data => {
    console.log('checkReimburseViewTableVisible success', data)
    if (data.returnCode === '000000') {
      let viewTableVisible = {}
      // if (data.sheetShow === '0') {
      //   viewTableVisible.travelTable = false
      // } else {
      //   viewTableVisible.travelTable = true
      // }
      if (data.feeShow === '0') {
        viewTableVisible.feePosition = false
      } else {
        viewTableVisible.feePosition = true
      }
      store.state.viewTableVisible = viewTableVisible
      console.log('store.state.viewTableVisible', paramObj.me.viewTableVisible)
    } else {
      paramObj.me.alert(data.returnMsg)
    }
    store.state.apiloading--
  }, (data, e) => {
    console.log('checkReimburseViewTableVisible error')
    store.state.apiloading--
  })
}

/**
 * 更新报销明细
 * @param store
 * @param paramObj
 */
actions.updateTableWh_bt_reimburse_dd_sub = function (store, paramObj) {
  let saveFlag = 'update'
  if (typeof paramObj.saveFlag !== 'undefined') {
    saveFlag = paramObj.saveFlag
  }
  store.state.apiloading++
  paramObj.me.httpBpmSaveBz({
    'data': paramObj.data,
    'keyFields': ['mid'],
    'saveFlag': saveFlag,
    'tableName': 'wh_bt_reimburse_dd_sub'
  }, data => {
    // actions.getDataFromTableDdSub(store, paramObj)
    store.state.apiloading--
  }, (data, e) => {
    // paramObj.me.alert('保存报销明细数据失败')
    paramObj.me.alert(paramObj.me.getResource('alert.unknown.error') + ':updateTableWh_bt_reimburse_dd_sub')
    store.state.apiloading--
  })
}

/**
 * 更新报销明细-的4个子表
 * @param store
 * @param paramObj
 */
actions.updateTableBxZb = function (store, paramObj) {
  let saveFlag = 'update'
  if (typeof paramObj.saveFlag !== 'undefined') {
    saveFlag = paramObj.saveFlag
  }
  store.state.apiloading++
  paramObj.me.httpBpmSaveBz({
    'data': paramObj.data,
    'keyFields': ['mmid'],
    'saveFlag': saveFlag,
    'tableName': paramObj.tableName
  }, data => {
    store.state.apiloading--
  }, (data, e) => {
    // paramObj.me.alert('保存报销明细-子明细数据失败')
    paramObj.me.alert(paramObj.me.getResource('alert.unknown.error') + ':updateTableBxZb')
    store.state.apiloading--
  })
}

/**
 * 起草保存报销明细的子表
 * @param store
 * @param paramObj
 */
actions.AJAX_Reim_011_Draft_SaveData = function (store, paramObj) {
  paramObj.data.rate = paramObj.data.rate + ''
  store.state.apiloading++
  paramObj.me.httpBpm({
    inputParameter: JSON.stringify({
      costingCenterCode: store.state.ssc.reimburse.whBtReimburse.reimbursecostcentercode,
      costingCenterName: store.state.ssc.reimburse.whBtReimburse.reimbursecompanycostcenter,
      whBtReimburseDdSub: JSON.stringify(paramObj.data),
      action: paramObj.action,
      fatherOrChild: paramObj.fatherOrChild,
      rate: store.state.ssc.reimburse.whBtReimburse.rate + ''
    }),
    'async': paramObj.async,
    'apiName': 'PREXPR@AJAX_Reim_011_Draft_SaveData'
  }, data => {
    if (data.returnCode === '000000') {
      store.state.returnCode = '000000'
      // store.state.ssc.reimburse.whBtReimburse.returnActualreimbursesum = data.returnActualreimbursesum
      // store.state.ssc.reimburse.whBtReimburse.returnChgActReimbSum = data.returnChgActReimbSum
      store.state.ssc.reimburse.whBtReimburse.chgTotalSum = data.returnChgReimbSum
      store.state.ssc.reimburse.whBtReimburse.totalsum = data.returnReimbursesum
      store.state.ssc.reimburse.whBtReimburse.costshareActtotalsum = data.returnCostShareSum
      store.state.gridSelectRow.ssc.reimburse.whBtReimburseDdSub.notincludetaxessum = data.ddsubNotincludetaxessum
      store.state.gridSelectRow.ssc.reimburse.whBtReimburseDdSub.taxrate = data.ddsubTaxrate
      store.state.gridSelectRow.ssc.reimburse.whBtReimburseDdSub.reimbursesum = data.ddsubReimbursesum
      store.state.gridSelectRow.ssc.reimburse.whBtReimburseDdSub.actualreimbursesum = data.ddsubActualreimbursesum
      store.state.ssc.reimburse.whBtReimburseRcmSub.totalSumFee = data.returnActualreimbursesum
    } else {
      store.state.returnCode = data.returnCode
      // paramObj.me.alert('保存起草报销明细-子明细数据失败')
      paramObj.me.alert(paramObj.me.getResource('alert.unknown.error') + ':AJAX_Reim_011_Draft_SaveData')
    }
    store.state.apiloading--
  }, (data, e) => {
    store.state.returnCode = 'unkown error'
    store.state.apiloading--
  })
}
actions.AJAX_Reim_013_Count_SubChild = function (store, paramObj) {
  store.state.apiloading++
  paramObj.me.httpBpm({
    inputParameter: JSON.stringify({
      tsId: store.state.tsId,
      userId: store.state.userId
    }),
    'async': paramObj.async,
    'apiName': 'PREXPR@AJAX_Reim_013_Count_SubChild'
  }, data => {
    if (data.returnCode === '000000') {
      console.log('0000000000222', data)
      store.state.fybxzb.total_ccf = data.total_ccf // 孙子表的车船费
      store.state.fybxzb.total_clbt = data.total_clbt // 孙子表的差旅补贴费
      store.state.fybxzb.total_czf = data.total_czf // 孙子表的出租车费
      store.state.fybxzb.total_zsf = data.total_zsf // 孙子表的住宿费
    } else {
      // paramObj.me.alert('保存起草报销明细-子明细数据汇总失败')
      paramObj.me.alert(paramObj.me.getResource('alert.unknown.error') + ':AJAX_Reim_013_Count_SubChild')
    }
    store.state.apiloading--
  }, (data, e) => {
    store.state.apiloading--
  })
}

/**
 * 制证的提交后的确定按钮执行业务逻辑
 * @param store
 * @param paramObj
 */
actions.submitApproveFee = function (store, paramObj) {
  var twOjb = {}
  twOjb.tsId = store.state.tsId
  twOjb.btNo = store.state.ssc.reimburse.whBtReimburse.btNo
  twOjb.totalsum = store.state.ssc.reimburse.whBtReimburse.totalsum
  twOjb.chargeagainstsum = store.state.ssc.reimburse.whBtReimburse.chargeagainstsum
  twOjb.isSuperscalar = store.state.ssc.reimburse.whBtReimburse.isSuperscalar
  twOjb.costshareActtotalsum = store.state.ssc.reimburse.whBtReimburse.costshareActtotalsum
  twOjb.standardmoney = store.state.ssc.reimburse.whBtReimburse.standardmoney
  twOjb.reimbursecompanycode = store.state.ssc.reimburse.whBtReimburse.reimbursecompanycode
  let mainBo = JSON.stringify(twOjb)

  let obj = {}
  obj.applyDate = paramObj.applyDate
  obj.tsId = store.state.tsId
  obj.userId = store.state.inst.userId
  obj.employeeNumber = store.state.ssc.reimburse.whBtReimburse.employeeNumber
  obj.whBtReimburse = mainBo

  let paramFinal = JSON.stringify(obj)
  console.log('=============', paramFinal)
  store.state.apiloading++
  paramObj.me.httpBpm({
    inputParameter: paramFinal,
    'apiName': 'PREXPR@AJAX_Reim_007_ApproveFee_Submit'
  }, data => {
    if (data.returnCode === '000000') {
      store.state.retMsg = ''
    } else {
      store.state.retMsg = data.returnMsg
      store.state.returnCode = data.returnCode
    }
    store.state.apiloading--
  }, (data, e) => {
    store.state.retMsg = 'unkown error'
    store.state.apiloading--
  })
}

actions.pdfPrint = function (store, paramObj) {
  store.state.apiloading++
  paramObj.me.httpBpm({
    inputParameter: JSON.stringify({
      tsId: store.state.tsId,
      userId: store.state.inst.userId
    }),
    'async': paramObj.async,
    'apiName': 'PREXPR@AJAX_Reim_009_View_Print'
  }, data => {
    if (data.returnCode === '000000') {
      paramObj.me.imageSrc = data.urlContent
      paramObj.me.printList = data.tsTaskDone.items
    } else {
      // paramObj.me.alert('业务失败')
      paramObj.me.alert(paramObj.me.getResource('alert.unknown.error') + ':pdfPrint')
    }
    store.state.apiloading--
  }, (data, e) => {
    store.state.apiloading--
  })
}
actions.queryIsScan = function (store, paramObj) {
  console.log('paramObj.me.ssc.reimburse.whBtReimburse.reimbursecompanycode', paramObj.me.ssc.reimburse.whBtReimburse.reimbursecompanycode)
  store.state.apiloading++
  paramObj.me.httpBpm({
    'companyCode': paramObj.me.ssc.reimburse.whBtReimburse.reimbursecompanycode,
    'async': false,
    'apiName': 'PREXPR@AJAX_SelectCompanyByCode'
  }, data => {
    console.log('queryIsScan data->', data)
    if (data && data.isScan) {
      store.state.isScan = data.isScan
    }
    store.state.apiloading--
  }, (data, e) => {
    store.state.apiloading--
  })
}
/**
 *调用提交逻辑。
 * @param store
 * @param paramObj
 * @constructor
 * @author  gyren
 * @date  20180521
 */
actions.draftSubmitService = function (store, paramObj) {
  store.state.apiloading++
  paramObj.me.httpBpm({
    inputParameter: JSON.stringify({
      tsId: store.state.tsId,
      userId: store.state.userId,
      whBtReimburse: JSON.stringify(store.state.ssc.reimburse.whBtReimburse),
      applyDate: paramObj.applyDate
    }),
    'async': paramObj.async,
    'apiName': 'PREXPR@AJAX_Reim_003_Draft_Submit'
  }, data => {
    if (data.returnCode === '000000') {
      store.state.retMsg = ''
    } else {
      store.state.retMsg = data.returnMsg
      // paramObj.me.alert('业务失败')
    }
    store.state.apiloading--
  }, (data, e) => {
    console.error('*************', e)
    store.state.retMsg = 'unkown error'
    store.state.apiloading--
  })
}
/**
 *重置数据中心值-报销明细；
 * @param store
 * @param paramObj
 */
actions.initWhBtReimburseDdSub = function (store, paramObj) {
  store.state.ssc.reimburse.whBtReimburseDdSub = []
}
/**
 *重置数据中心值-成本中心；
 * @param store
 * @param paramObj
 */
actions.initWhBtReimburseCostShare = function (store, paramObj) {
  store.state.ssc.reimburse.whBtReimburseCostshare = []
}
/**
 *重置数据中心值-车船费；
 * @param store
 * @param paramObj
 */
actions.initWhBtFaredetails = function (store, paramObj) {
  store.state.ssc.reimburse.whBtFareDetails = []
}
/**
 *重置数据中心值-住宿费；
 * @param store
 * @param paramObj
 */
actions.initWhBtStaydetails = function (store, paramObj) {
  store.state.ssc.reimburse.whBtStayDetails = []
}
/**
 *重置数据中心值-差旅补贴；
 * @param store
 * @param paramObj
 */
actions.initWhBtTravelsubsidydetails = function (store, paramObj) {
  store.state.ssc.reimburse.whBtTravelsubsidydetails = []
}
actions.initChooseList = function (store, paramObj) {
  store.state.ssc.reimburse[paramObj.name] = []
}
/**
 * 保存后清空上面的帽子
 * @param store
 * @param paramObj
 */
actions.resetGridSelectRowWhBtReimburseDdSub = function (store, paramObj) {
  store.state.ssc.reimburse.budgetSubjectList = []
  store.state.gridSelectRow.ssc.reimburse.whBtReimburseDdSub = {
    mid: '', // V3_modi:主键,primary key,primary key
    tsId: '', // V3_modi:外键,foreign key,foreign key
    internalordercode: '', // V3_modi:内部订单代码,internal order code,internal order code
    internalordername: '', // V3_modi:内部订单名称,internal order name,internal order name
    subjectcode: '', // V3_modi:科目代码,subject code,subject code
    subjectname: '', // V3_modi:科目名称,subject name,subject name
    notincludetaxessum: '', // V3_modi:不含税金额,excluding tax sum,excluding tax sum
    taxrate: '', // V3_modi:税额,taxrate,taxrate
    reimbursesum: '', // V3_modi:报销金额,reimburse sum,reimburse sum
    actualreimbursesum: '', // V3_modi:实际报销金额,actual reimburse sum,actual reimburse sum
    summary: '', // V3_modi:摘要,summary,summary
    travelarea: '', // V3_modi:出差地区 【国内、国外】,travel area,travel area
    rate: '', // V3_add:汇率
    chgReimbSum: '', // V3_add:报销金额【本位币】
    receiveReason: '', // V3_add:接待事由
    receiveDate: '', // V3_add:接待日期
    receivePlace: '', // V3_add:接待地点
    costomer: '', // V3_add:来宾人员
    master: '', // V3_add:陪同人员
    addVar1: '', // V3_add:备用1
    addVar2: '', // V3_add:备用2
    addVar3: '', // V3_add:备用3
    chgActReimbSum: '' // V3_add:实际报销金额【本位币】,actual travel area,travel area
  }
}
/**
 * 保存后清空上面的帽子
 * @param store
 * @param paramObj
 */
actions.resetGridSelectRowWhBtReimburseCostShare = function (store, paramObj) {
  store.state.gridSelectRow.ssc.reimburse.whBtReimburseCostshare = {
    tsId: '', // tsId
    mid: '', // mid
    costcentercode: '', // 成本中心代码
    costcentername: '', // 成本中心名称
    internalordercode: '', // 内部订单代码
    internalordername: '', // 内部订单名称
    subjectcode: '', // 科目代码
    subjectname: '', // 科目名称
    notaxamountCurrency: '', // 不含税金额(本位币)
    taxCurrency: '', // 税额(本位币)
    reimbursesumCurrency: '', // 申请报销金额(本位币)
    actualreimbursesumCurrency: '', // 实际报销金额(本位币)
    costcenterbudget: '', // 成本中心预算(本位币)
    notaxamount: '', // 报销币别不含税金额
    tax: '', // 报销币别税额
    reimbursesum: '', // 报销币别申请报销金额
    actualreimbursesum: '' // 报销币别实际报销金额
  }
}
// 车船费
actions.resetGridSelectRowWhBtFareDetails = function (store, paramObj) {
  store.state.gridSelectRow.ssc.reimburse.whBtFareDetails = {
    mmid: '', // V3_modi:主键,primary key,primary key
    mid: '', // V3_modi:外键,foreign key,foreign key
    departuredate: '', // V3_modi:出发日期,departure date,departure date
    transportation: '', // V3_modi:交通工具,transportation,transportation
    billssum: '', // V3_modi:票面金额,bills sum,bills sum
    actualremibursesum: '', // V3_modi:实际报销金额,actua reimburse sum,actual reimburse sum
    remark: '', // V3_modi:备注,remark,remark
    tsId: '', //
    country: '', // V3_add:国家
    city: '', // V3_add:城市
    leaveDate: '', // V3_add:离开日期
    together: '', // V3_add:同行人员
    notaxamount: '', //
    tax: '' //
  }
}
// 住宿费
actions.resetGridSelectRowWhBtStayDetails = function (store, paramObj) {
  store.state.gridSelectRow.ssc.reimburse.whBtStayDetails = {
    mmid: '', // V3_modi:主键,primary key,primary key
    mid: '', // V3_modi:外键,foreign key,foreign key
    city: '', // V3_modi:城市,city,city
    hotelsname: '', // V3_modi:酒店名称,hotels name,hotels name
    days: '', // V3_modi:入住天数,accommodation days,accommodation days
    billssum: '', // V3_modi:票面金额,bills sum,bills sum
    actualremibursesum: '', // V3_modi:实际报销金额,actual reimburse sum,actual reimburse sum
    remark: '', // V3_modi:备注,remark,remark
    tsId: '', //
    country: '', // V3_add:国家
    stayDate: '', // V3_add:入住日期
    together: '', // V3_add:入住人员
    personNum: '', // V3_add:入住人数
    notaxamount: '', //
    tax: '', //
    togetherMan: '', //
    togetherWoman: '' //
  }
}
// 补贴费
actions.resetGridSelectRowWhBtTravelSubsidyDetails = function (store, paramObj) {
  store.state.gridSelectRow.ssc.reimburse.whBtTravelSubsidyDetails = {
    mmid: '', // V3_modi:主键,primary key,primary key
    mid: '', // V3_modi:外键,foreign key,foreign key
    city: '', // V3_modi:城市,city,city
    subsidycriteria: '', // V3_modi:补贴标准,allowance standard,allowance standard
    remaindays: '', // V3_modi:停留天数,remain days,remain days
    subsidydays: '', // V3_modi:补贴天数,allowance days,allowance days
    actualremibursesum: '', // V3_modi:实际补贴金额,actual reimburse sum,actual reimburse sum
    remark: '', // V3_modi:备注,remark,remark
    tsId: '' //
  }
}
// 出租费
actions.resetGridSelectRowWhBtTransportationDetails = function (store, paramObj) {
  store.state.gridSelectRow.ssc.reimburse.whBtTransportationDetails = {
    mmid: '', // V3_modi:主键,primary key,primary key
    mid: '', // V3_modi:外键,foreign key,foreign key
    city: '', // V3_modi:城市,city,city
    transportation: '', // V3_modi:交通工具,transportation,transportation
    billscount: '', // V3_modi:票据张数,bills count,bills count
    billssum: '', // V3_modi:票面金额,bills sum,bills sum
    actualremibursesum: '', // V3_modi:实际报销金额,actual reimburse sum,actual reimburse sum
    remark: '', // V3_modi:备注,remark,remark
    tsId: '' //
  }
}

// 根据tspiid组装链接
actions.encryptTsIdForHyperView = function (store, paramObj) {
  console.log('encryptTsIdForHyperView tsId', paramObj.tsId)
  store.state.apiloading++
  paramObj.me.httpBpm({
    tsId: paramObj.tsId,
    'async': false,
    'apiName': 'EBSA@AJAX_EncryptTsIdForHyperView'
  }, data => {
    console.log('encryptTsIdForHyperView data success', data.encrypt_TsId)
    store.state.encryptTsId = data.encrypt_TsId
    store.state.apiloading--
  }, (data, e) => {
    console.log('encryptTsIdForHyperView data error', data)
    store.state.apiloading--
  })
}
/**
 *检查是否存在相同的报销科目；
 * @param store
 * @param paramObj
 */
actions.CheckSubjectExists = function (store, paramObj) {
  console.log('CheckSubjectExists tsId', paramObj.tsId)
  store.state.apiloading++
  paramObj.me.httpBpm({
    tsId: paramObj.data.tsId,
    mid: store.state.gridSelectRow.ssc.reimburse.whBtReimburseDdSub.mid,
    innerOrder: store.state.gridSelectRow.ssc.reimburse.whBtReimburseDdSub.internalordercode,
    subjectCode: store.state.gridSelectRow.ssc.reimburse.whBtReimburseDdSub.subjectcode,
    'async': false,
    'apiName': 'PREXPR@AJAX_CheckSubjectExists'
  }, data => {
    console.log('AJAX_CheckSubjectExists data success', data.count)
    store.state.ssc.reimburse.checkExistResult = data.count
    store.state.apiloading--
  }, (data, e) => {
    console.log('AJAX_CheckSubjectExists data error', data)
    store.state.apiloading--
  })
}
/**
 * 查找差旅费对应的mid，一个单据只有一个差旅费mid；
 * @param store
 * @param paramObj
 */
actions.getbxmxMidFromDb = function (store, paramObj) {
  store.state.apiloading++
  paramObj.me.httpBpm({
    inputParameter: JSON.stringify({
      'tsId': store.state.tsId
    }),
    'apiName': 'PREXPR@AJAX_Reim_016_Query_CLFMid',
    async: paramObj.async
  }, data => {
    if (data.returnCode === '000000') {
      // let resObj = JSON.parse(data.returnMid)
      store.commit('SetDataSscReimbursebxmxMid', data.returnMid)
      paramObj.succfunc && paramObj.succfunc()
    } else {
      // paramObj.me.alert('业务失败')
      paramObj.me.alert(paramObj.me.getResource('alert.unknown.error') + ':getbxmxMidFromDb')
    }
    store.state.apiloading--
  }, (data, e) => {
    store.state.apiloading--
  })
}
/**
 * 影像链接驳回；marked by gyren
 * @param store
 * @param paramObj
 */
actions.rejectPictureLink = function (store, paramObj) {
  store.state.apiloading++
  paramObj.me.httpBpm({
    'tsId': store.state.tsId,
    'apiName': 'PREXPR@AJAX_rejectReimPicLink',
    async: paramObj.async
  }, data => {
    if (data.ret === 'S') {
      // paramObj.me.alert(coachViewUtil.getResource('alert.rejectPictureY'))
      store.commit('SetDataSscReimburseRetMsg', 'alert.rejectPictureY')
      store.state.ssc.reimburse.whBtReimburse.processlinkopentext = ''
      paramObj.succfunc && paramObj.succfunc()
    } else {
      store.commit('SetDataSscReimburseRetMsg', data.msg)
      // paramObj.me.alert(data.msg)
    }
    store.state.apiloading--
  }, (data, e) => {
    store.commit('SetDataSscReimburseRetMsg', data.msg)
    store.state.apiloading--
  })
}
/**
 *计算总金额
 * @param store
 * @param paramObj
 */
actions.callTotalMoney = function (store, paramObj) {
  store.state.apiloading++
  paramObj.me.httpBpm({
    'tsId': paramObj.tsId,
    'apiName': 'PREXPR@AJAX_ReimburseTotalSum',
    async: paramObj.async
  }, data => {
    store.commit('SetDataSscReimburseAmountSum', data.amountSum)
    store.state.ssc.reimburse.whBtReimburseRcmSub.totalSumFee = data.amountSum
    paramObj.succfunc && paramObj.succfunc()
    store.state.apiloading--
  }, (data, e) => {
    // paramObj.me.alert('业务失败')
    paramObj.me.alert(paramObj.me.getResource('alert.unknown.error') + ':callTotalMoney')
    store.state.apiloading--
  })
}

/**
 * 更新报销总金额 --gyren
 * @param store
 * @param paramObj
 */
actions.updateReimburseSumByMid = function (store, paramObj) {
  store.state.apiloading++
  paramObj.me.httpBpm({
    'mid': paramObj.mid,
    'apiName': 'PREXPR@AJAX_UpdateReimDetailsSumByMidFee',
    async: paramObj.async
  }, data => {
    store.commit('SetDataSscReimburseCheckResult', 'pass')
    paramObj.succfunc && paramObj.succfunc()
    store.state.apiloading--
  }, (data, e) => {
    // paramObj.me.alert('业务失败')
    paramObj.me.alert(paramObj.me.getResource('alert.unknown.error') + ':updateReimburseSumByMid')
    store.commit('SetDataSscReimburseCheckResult', 'nopass')
    store.state.apiloading--
  })
}
actions.updateCardMakingSumByMid4Vue = function (store, paramObj) {
  store.state.apiloading++
  paramObj.me.httpBpm({
    'mid': store.state.gridSelectRow.ssc.reimburse.whBtReimburseDdSub.mid,
    'notCesse': store.state.gridSelectRow.ssc.reimburse.whBtReimburseDdSub.notincludetaxessum,
    'cesse': store.state.gridSelectRow.ssc.reimburse.whBtReimburseDdSub.taxrate,
    'apiName': 'PREXPR@AJAX_UpdateCardMakingByMid',
    async: paramObj.async
  }, data => {
    if (data.status !== '1') {
      store.commit('SetDataSscReimburseApproveFeeUpdateResult', 'pass')
      paramObj.succfunc && paramObj.succfunc()
    } else {
      store.commit('SetDataSscReimburseApproveFeeUpdateResult', 'nopass')
      paramObj.succfunc && paramObj.succfunc()
    }
    store.state.apiloading--
  }, (data, e) => {
    // paramObj.me.alert('业务失败')
    paramObj.me.alert(paramObj.me.getResource('alert.unknown.error') + ':updateCardMakingSumByMid4Vue')
    store.commit('SetDataSscReimburseApproveFeeUpdateResult', 'nopass')
    store.state.apiloading--
  })
}
/**
 *制证环节插入一条制证信息；
 * @param store
 * @param paramObj
 */
actions.insertDataForRcmDetail = function (store, paramObj) {
  store.state.apiloading++
  store.state.returnCode = '000000'
  paramObj.me.httpBpm({
    'mid': paramObj.data,
    'apiName': 'PREXPR@AJAX_InsertCardMakingByMid',
    'async': paramObj.async
  }, data => {
    store.state.returnCode = '000000'
    store.state.apiloading--
  }, (data, e) => {
    store.state.returnCode = 'unkown error'
    store.state.apiloading--
  })
}

/**
 * 费用岗制证保存各表数据
 * @param store
 * @param paramObj
 */
actions.AJAX_Reim_021_ApproveFee_SaveData = function (store, paramObj) {
  paramObj.data.rate = paramObj.data.rate + ''
  store.state.apiloading++
  paramObj.me.httpBpm({
    inputParameter: JSON.stringify({
      costingCenterCode: store.state.ssc.reimburse.whBtReimburse.reimbursecostcentercode,
      costingCenterName: store.state.ssc.reimburse.whBtReimburse.reimbursecompanycostcenter,
      whBtReimburseDdSub: JSON.stringify(paramObj.data),
      action: paramObj.action,
      fatherOrChild: paramObj.fatherOrChild,
      rate: store.state.ssc.reimburse.whBtReimburse.rate + ''
    }),
    'async': paramObj.async,
    'apiName': 'PREXPR@AJAX_Reim_021_ApproveFee_SaveData'
  }, data => {
    if (data.returnCode === '000000') {
      store.state.returnCode = '000000'
      store.state.ssc.reimburse.whBtReimburse.chgTotalSum = data.returnChgReimbSum
      store.state.ssc.reimburse.whBtReimburse.totalsum = data.returnReimbursesum
      store.state.ssc.reimburse.whBtReimburse.costshareActtotalsum = data.returnCostShareSum
      store.state.gridSelectRow.ssc.reimburse.whBtReimburseDdSub.notincludetaxessum = data.ddsubNotincludetaxessum
      store.state.gridSelectRow.ssc.reimburse.whBtReimburseDdSub.taxrate = data.ddsubTaxrate
      store.state.gridSelectRow.ssc.reimburse.whBtReimburseDdSub.reimbursesum = data.ddsubReimbursesum
      store.state.gridSelectRow.ssc.reimburse.whBtReimburseDdSub.actualreimbursesum = data.ddsubActualreimbursesum
      store.state.ssc.reimburse.whBtReimburseRcmSub.totalSumFee = data.returnActualreimbursesum
    } else {
      store.state.returnCode = data.returnCode
      store.state.retMsg = data.returnMsg
    }
    store.state.apiloading--
  }, (data, e) => {
    store.state.returnCode = 'unkown error'
    store.state.retMsg = 'unkown error'
    store.state.apiloading--
  })
}
/**
 * 费用岗制证孙子表平衡各表数据
 * @param store
 * @param paramObj
 */
actions.AJAX_Reim_031_SubApproveFee_SaveData = function (store, paramObj) {
  store.state.apiloading++
  paramObj.me.httpBpm({
    inputParameter: JSON.stringify({
      tsId: paramObj.tsId,
      mid: paramObj.mid,
      action: paramObj.action,
      rate: store.state.ssc.reimburse.whBtReimburse.rate + ''
    }),
    'async': paramObj.async,
    'apiName': 'PREXPR@AJAX_Reim_031_SubApproveFee_SaveData'
  }, data => {
    if (data.returnCode === '000000') {
      store.state.returnCode = '000000'
      store.state.ssc.reimburse.whBtReimburse.chgTotalSum = data.returnChgReimbSum
      store.state.ssc.reimburse.whBtReimburse.totalsum = data.returnReimbursesum
      store.state.ssc.reimburse.whBtReimburse.costshareActtotalsum = data.returnCostShareSum
      store.state.gridSelectRow.ssc.reimburse.whBtReimburseDdSub.notincludetaxessum = data.ddsubNotincludetaxessum
      store.state.gridSelectRow.ssc.reimburse.whBtReimburseDdSub.taxrate = data.ddsubTaxrate
      store.state.gridSelectRow.ssc.reimburse.whBtReimburseDdSub.reimbursesum = data.ddsubReimbursesum
      store.state.gridSelectRow.ssc.reimburse.whBtReimburseDdSub.actualreimbursesum = data.ddsubActualreimbursesum
      store.state.ssc.reimburse.whBtReimburseRcmSub.totalSumFee = data.returnActualreimbursesum
    } else {
      store.state.returnCode = data.returnCode
      store.state.retMsg = data.returnMsg
    }
    store.state.apiloading--
  }, (data, e) => {
    store.state.returnCode = 'unkown error'
    store.state.retMsg = 'unkown error'
    store.state.apiloading--
  })
}
/**
 * 调用ajax在起草提交校验
 * @param store
 * @param paramObj
 */
actions.draftCallAjaxCheckBeforeSubmit = function (store, paramObj) {
  store.state.apiloading++
  paramObj.me.httpBpm({
    'tsId': store.state.tsId,
    'userId': store.state.userId,
    'pageType': paramObj.data,
    'applyDate': paramObj.applyDate,
    'reimbursecompanycode': store.state.ssc.reimburse.whBtReimburse.reimbursecompanycode,
    'standardmoney': store.state.ssc.reimburse.whBtReimburse.standardmoney,
    'creator': store.state.hsInput.creator.userId,
    'apiName': 'PREXPR@AJAX_Reim_019_DraftCheckBeforeSubmit',
    async: paramObj.async
  }, data => {
    if (data.returnCode === '000000') {
      store.state.failMids = ''
      paramObj.succfunc && paramObj.succfunc()
    } else {
      if (data.failMids && data.failMids !== '') {
        store.state.failMids = data.failMids
        console.log('store.state.failMids>>>>', store.state.failMids)
      }
      store.commit('SetDataSscReimburseRetMsg', data.retMsg)
    }
    store.state.apiloading--
  }, (data, e) => {
    // paramObj.me.alert('业务失败')
    store.commit('SetDataSscReimburseRetMsg', 'alert.unknown.error')
    store.state.apiloading--
  })
}
/**
 * 调用018接口校验数据 marked by gyren
 * @param store
 * @param paramObj
 */
actions.approveFeeCallAjaxCheckBeforeMaking = function (store, paramObj) {
  store.state.apiloading++
  paramObj.me.httpBpm({
    'tsId': store.state.tsId,
    'userId': store.state.userId,
    'pageType': paramObj.data,
    'apiName': 'PREXPR@AJAX_Reim_018_ApproveFeeCheckBeforeMaking',
    async: paramObj.async
  }, data => {
    if (data.returnCode === '000000') {
      store.commit('SetDataSscReimburseRetMsg', 'pass')
      paramObj.succfunc && paramObj.succfunc()
    } else {
      store.commit('SetDataSscReimburseRetMsg', data.returnMsg)
    }
    store.state.apiloading--
  }, (data, e) => {
    // paramObj.me.alert('业务失败')
    paramObj.me.alert(paramObj.me.getResource('alert.unknown.error') + ':approveFeeCallAjaxCheckBeforeMaking')
    store.commit('SetDataSscReimburseRetMsg', 'alert.unknown.error')
    store.state.apiloading--
  })
}
/**
 * 调用018接口校验数据 marked by gyren
 * @param store
 * @param paramObj
 */
actions.saveDataBeforeMakeCert = function (store, paramObj) {
  store.state.apiloading++
  store.state.retMsg = '000000'
  paramObj.me.httpBpm({
    'tsId': store.state.tsId,
    'postingDate': paramObj.postingDate,
    'defraySum': paramObj.defraySum,
    'totalSumFee': paramObj.totalSumFee,
    'chargeAgainstSumFee': paramObj.chargeAgainstSumFee,
    'unpaidAggregateAmountFee': paramObj.unpaidAggregateAmountFee,
    'apiName': 'PREXPR@AJAX_UpdateBeforeMakeCert',
    async: paramObj.async
  }, data => {
    if (data.count + '' === '1') {
      store.commit('SetDataSscReimburseRetMsg', 'pass')
      paramObj.succfunc && paramObj.succfunc()
    } else {
      store.commit('SetDataSscReimburseRetMsg', 'alert.gxzzsjyc')
    }
    store.state.apiloading--
  }, (data, e) => {
    // paramObj.me.alert('业务失败')
    paramObj.me.alert(paramObj.me.getResource('alert.unknown.error') + ':saveDataBeforeMakeCert')
    store.commit('SetDataSscReimburseRetMsg', 'alert.unknown.error')
    store.state.apiloading--
  })
}
/**
 * 调用接口制证 marked by gyren
 * @param store
 * @param paramObj
 */
actions.makeCert = function (store, paramObj) {
  store.state.apiloading++
  store.state.retMsg = '000000'
  paramObj.me.httpBpm({
    'tsId': store.state.tsId,
    'againstsum': paramObj.againstsum,
    'apiName': 'PREXPR@AJAX_MakeCertByTsId',
    async: paramObj.async
  }, data => {
    if (data.ret === 'S') {
      store.commit('SetDataSscReimburseCertNo', data.certNo)
      store.state.retMsg = 'pass'
      paramObj.succfunc && paramObj.succfunc()
    } else {
      store.commit('SetDataSscReimburseRetMsg', data.msg)
    }
    store.state.apiloading--
  }, (data, e) => {
    // paramObj.me.alert('业务失败')
    paramObj.me.alert(paramObj.me.getResource('alert.unknown.error') + ':makeCert')
    store.commit('SetDataSscReimburseRetMsg', 'alert.unknown.error')
    store.state.apiloading--
  })
}
/**
 *制证明细表
 * @param store
 * @param paramObj
 */
actions.resetGridSelectRowWhBtReimburseRcmDetail = function (store, paramObj) {
  store.state.gridSelectRow.ssc.reimburse.whBtReimburseRcmDetail = {
    mid: '', // V3_modi:辅助id,assistant id,assistant id
    tsId: '', // V3_modi:外键,foreign key,foreign key
    accoutingsubject: '', // V3_modi:核算科目【只取前10位】,accounting subject,accounting subject
    costcentercode: '', // V3_modi:成本中心代码,cost center code,cost center code
    subjecttype: '', // V3_modi:科目类型,subject type,subject type
    notincludetaxessum: '', // V3_modi:不含税金额,excluding tax sum,excluding tax sum
    taxrate: '', // V3_modi:税额,taxrate,taxrate
    costcentername: '', // V3_modi:成本中心名称,cost center name,cost center name
    ordercode: '', // V3_modi:内部订单代码,internal order code,internal order code
    subjectcode: '', // V3_modi:核算科目代码,accounting subject code,accounting subject code
    mmid: '', // V3_modi:主键,primary key,primary key
    transferTax: '', //
    notincludetaxessumBx: '', // 报销币别不含税金额
    taxrateBx: '', // 报销币别税额
    transferTaxBx: '', // 报销币别转出税额
    orderName: '' // 内部订单名称
  }
}
/**
 * 统计费用分摊表金额 marked by gyren
 * @param store
 * @param paramObj
 */
actions.calCostShareActSum = function (store, paramObj) {
  store.state.apiloading++
  paramObj.me.httpBpm({
    'tsId': store.state.tsId,
    'apiName': 'PREXPR@AJAX_CalCostShareActSum',
    async: paramObj.async
  }, data => {
    store.state.ssc.reimburse.whBtReimburse.costshareActtotalsum = data.actSum
    paramObj.succfunc && paramObj.succfunc()
    store.state.apiloading--
  }, (data, e) => {
    console.error('error===', e)
    store.state.apiloading--
  })
}
/**
 * 生成一条制证明细 marked by gyren
 * @param store
 * @param paramObj
 */
actions.approveFeeAddCertMaking = function (store, paramObj) {
  store.state.apiloading++
  paramObj.me.httpBpm({
    'tsId': store.state.tsId,
    'apiName': 'PREXPR@Ajax_AddCarkMaking',
    async: paramObj.async
  }, data => {
    paramObj.succfunc && paramObj.succfunc()
    store.state.apiloading--
  }, (data, e) => {
    console.error('error===', e)
    store.state.apiloading--
  })
}
/**
 * 调用Ajax清除已登记信息 marked by gyren
 * @param store
 * @param paramObj
 */
actions.clearRegInfo = function (store, paramObj) {
  store.state.apiloading++
  paramObj.me.httpBpm({
    'tsId': store.state.tsId,
    'mid': paramObj.mid,
    'apiName': 'PREXPR@AJAX_deleteReimDetaiByMid',
    async: paramObj.async
  }, data => {
    paramObj.succfunc && paramObj.succfunc()
    store.state.apiloading--
  }, (data, e) => {
    console.error('error===', e)
    store.state.apiloading--
  })
}

/**
 * 批量删除报销明细及其相关数据
 * @param store
 * @param paramObj
 */
actions.AJAX_Reim_020_DraftDel_MultiData = function (store, paramObj) {
  store.state.apiloading++
  paramObj.me.httpBpm({
    inputParameter: JSON.stringify({
      tsId: store.state.tsId,
      mids: paramObj.mids
    }),
    'async': paramObj.async,
    'apiName': 'PREXPR@AJAX_Reim_020_DraftDel_MultiData'
  }, data => {
    if (data.returnCode === '000000') {
      store.state.retMsg = ''
      store.state.ssc.reimburse.whBtReimburse.chgTotalSum = data.returnChgReimbSum
      store.state.ssc.reimburse.whBtReimburse.totalsum = data.returnReimbursesum
      store.state.ssc.reimburse.whBtReimburse.costshareActtotalsum = data.returnCostShareSum
      store.state.ssc.reimburse.whBtReimburseRcmSub.totalSumFee = data.returnActualreimbursesum
    } else {
      store.state.retMsg = data.returnCode
    }
    store.state.apiloading--
  }, (data, e) => {
    store.state.retMsg = 'unkown error'
    store.state.apiloading--
  })
}
/**
 * 请求合并，多表数据请求,一次返回returnData  JSON格式
 * @param store
 * @param paramObj
 */
actions.getDataSscReimburseFromMoreTable = function (store, paramObj) {
  store.state.apiloading++
  paramObj.me.httpBpm({
    inputParameter: JSON.stringify({
      'tsId': store.state.tsId,
      'tableNames': paramObj.tableNames,
      'searchClause': JSON.stringify({
        sql: ' TS_ID=?',
        parameters: [store.state.tsId]
      }),
      'dictFields': paramObj.me.dictFields,
      'page_LineNbr': 10,
      'begin_line': 0,
      'countFlag': 1,
      'BB': paramObj.BB
    }),
    async: paramObj.async,
    'apiName': 'PREXPR@Ajax_Reim_000_RetrieveProcessBzData'
  }, (data) => {
    if (data && data.returnCode === '000000') {
      let resObj = JSON.parse(data.returnData)
      // 1、给数据中心各业务表绑定数据
      for (let i = 0; i < paramObj.tableNames.split(',').length; i++) {
        let tableName = paramObj.tableNames.split(',')[i]
        let singleData = resObj[tableName]
        let singleObj = JSON.parse(singleData)
        let totalNbr = singleObj.totalNbr
        let totalNb = parseInt(totalNbr + '')
        let jsonResult = JSON.parse(singleObj.jsonResult)
        let vtableName = tableName.toLowerCase()
        switch (vtableName) {
          case 'wh_bt_reimburse': {
            if (jsonResult[0]) {
              store.commit('SetDataSscReimburseWhBtReimburse', jsonResult[0])
            }
            break
          }
          case 'wh_bt_reimburse_dd_sub': {
            if (jsonResult) {
              console.log('SetDataSscReimburseWhBtReimburseDdSub jsonResult', jsonResult, totalNbr)
              if (totalNb > 0 && totalNb > store.state.gridPageInfo.ssc.reimburse.whBtReimburseDdSub.max) {
                store.commit('upGridPageInfoWithPathAndValue', {
                  path: 'whBtReimburseDdSub',
                  name: 'max',
                  value: totalNb
                })
              }
              store.commit('SetDataSscReimburseWhBtReimburseDdSub', jsonResult)
            }
            break
          }
          case 'wh_bt_reimburse_costshare': {
            if (jsonResult) {
              console.log('SetDataSscReimburseWhBtReimburseCostshare jsonResult', jsonResult, totalNbr)
              if (totalNb > 0 && totalNb > store.state.gridPageInfo.ssc.reimburse.whBtReimburseCostshare.max) {
                store.commit('upGridPageInfoWithPathAndValue', {
                  path: 'whBtReimburseCostshare',
                  name: 'max',
                  value: totalNb
                })
              }
              store.commit('SetDataSscReimburseWhBtReimburseCostshare', jsonResult)
            }
            if (jsonResult.length > 0 && paramObj.me.pageType === paramObj.me.pageTypeEnum.approve) {
              store.state.viewTableVisible.costCenterBudget = true
              for (let m = 0; m < jsonResult.length; m++) {
                if (jsonResult[0].costcentercode !== jsonResult[m].costcentercode) {
                  store.state.viewTableVisible.costCenterBudget = false
                  break
                }
              }
            }
            if (store.state.viewTableVisible.costCenterBudget === true) {
              // 如果显示可用预算，那么查出来
              let params = {}
              let params2 = {}
              params.lang = store.state.lang
              params.currentPage = ''
              params.lineNumber = ''
              params.field1 = ''
              params.field2 = ''
              params.Data = []
              for (var m = 0; m < jsonResult.length; m++) {
                params.Data[m] = {}
                params.Data[m].costCenterCode = jsonResult[m].costcentercode
                params.Data[m].internalOrderCode = jsonResult[m].internalordercode
                params.Data[m].subjectCode = jsonResult[m].subjectcode
                params.Data[m].field3 = ''
                params.Data[m].field4 = ''
              }
              console.log('getDataFromTableCostshare params->', params)
              params2.DT_321_BPM_AvailableBudgetQuery = params
              params2.apiName = 'PREXPR@AJAX_321_AvailableBudgetQuery'
              console.log('getDataFromTableCostshare params2->', params2)
              store.state.apiloading++
              paramObj.me.httpBpm(params2, data2 => {
                console.log('getDataFromTableCostshare data2->', data2)
                if (data2.DT_321_BPM_AvailableBudgetQuery_Resp.executeStatus === 'S') {
                  console.log('store.state.ssc.reimburse.whBtReimburse.rate->', store.state.ssc.reimburse.whBtReimburse.rate)
                  let rate = 1
                  if (store.state.ssc.reimburse.whBtReimburse.rate && store.state.ssc.reimburse.whBtReimburse.rate > 0) {
                    rate = store.state.ssc.reimburse.whBtReimburse.rate
                  }
                  let listLen = data2.DT_321_BPM_AvailableBudgetQuery_Resp.Data.items.length
                  if (listLen > 0) {
                    for (var n = 0; n < listLen; n++) {
                      jsonResult[n].costcenterbudget = (data2.DT_321_BPM_AvailableBudgetQuery_Resp.Data.items[n].availableAmount) * rate
                    }
                  } else {
                    // paramObj.me.alert('业务失败,未获取到订单数据')
                    paramObj.me.alert(paramObj.me.getResource('alert.unknown.error') + ':getDataSscReimburseFromMoreTable')
                  }
                  console.log('getDataFromTableCostshare data after->', jsonResult)
                  store.state.apiloading--
                } else {
                  // paramObj.me.alert('业务失败')
                  paramObj.me.alert(paramObj.me.getResource('alert.unknown.error') + ':getDataSscReimburseFromMoreTable')
                  store.state.apiloading--
                }
              }, (data, e) => {
              })
            }
            break
          }
          case 'wh_bt_travelsubsidydetails': {
            if (jsonResult) {
              console.log('SetDataSscReimburseWhBtTravelSubsidyDetails jsonResult', jsonResult, totalNbr)
              if (totalNb > 0 && totalNb > store.state.gridPageInfo.ssc.reimburse.whBtTravelSubsidyDetails.max) {
                store.commit('upGridPageInfoWithPathAndValue', {
                  path: 'whBtTravelSubsidyDetails',
                  name: 'max',
                  value: totalNb
                })
              }
              store.commit('SetDataSscReimburseWhBtTravelSubsidyDetails', jsonResult)
            }
            break
          }
          case 'wh_bt_transportationdetails': {
            if (jsonResult) {
              console.log('SetDataSscReimburseWhBtTransportationDetails jsonResult', jsonResult, totalNbr)
              if (totalNb > 0 && totalNb > store.state.gridPageInfo.ssc.reimburse.whBtTransportationDetails.max) {
                store.commit('upGridPageInfoWithPathAndValue', {
                  path: 'whBtTransportationDetails',
                  name: 'max',
                  value: totalNb
                })
              }
              store.commit('SetDataSscReimburseWhBtTransportationDetails', jsonResult)
            }
            break
          }
          case 'wh_bt_faredetails': {
            if (jsonResult) {
              console.log('SetDataSscReimburseWhBtFareDetails jsonResult', jsonResult, totalNbr)
              if (totalNb > 0 && totalNb > store.state.gridPageInfo.ssc.reimburse.whBtFareDetails.max) {
                store.commit('upGridPageInfoWithPathAndValue', {
                  path: 'whBtFareDetails',
                  name: 'max',
                  value: totalNb
                })
              }
              store.commit('SetDataSscReimburseWhBtFareDetails', jsonResult)
            }
            break
          }
          case 'wh_bt_staydetails': {
            if (jsonResult) {
              console.log('SetDataSscReimburseWhBtStayDetails jsonResult', jsonResult, totalNbr)
              if (totalNb > 0 && totalNb > store.state.gridPageInfo.ssc.reimburse.whBtStayDetails.max) {
                store.commit('upGridPageInfoWithPathAndValue', {
                  path: 'whBtStayDetails',
                  name: 'max',
                  value: totalNb
                })
              }
              store.commit('SetDataSscReimburseWhBtStayDetails', jsonResult)
            }
            break
          }
          case 'wh_vbt_reimburse_rcm_details': {
            if (jsonResult) {
              console.log('SetDataSscReimburseWhBtReimburseRcmDetails jsonResult', jsonResult, totalNbr)
              if (totalNb > 0 && totalNb > store.state.gridPageInfo.ssc.reimburse.whBtReimburseRcmDetail.max) {
                store.commit('upGridPageInfoWithPathAndValue', {
                  path: 'whBtReimburseRcmDetail',
                  name: 'max',
                  value: totalNb
                })
              }
              store.commit('SetDataSscReimburseWhBtReimburseRcmDetails', jsonResult)
            }
            break
          }
          case 'wh_bt_reimburse_rcm_sub': {
            if (jsonResult[0]) {
              console.log('SetDataSscReimburseWhBtReimburseRcmSub jsonResult', jsonResult[0], totalNbr)
              if (totalNb > 0 && totalNb > store.state.gridPageInfo.ssc.reimburse.whBtReimburseRcmSub.max) {
                store.commit('upGridPageInfoWithPathAndValue', {
                  path: 'whBtReimburseRcmSub',
                  name: 'max',
                  value: totalNb
                })
              }
              store.commit('SetDataSscReimburseWhBtReimburseRcmSub', jsonResult[0])
            }
            break
          }
        }
      }
      // 2、如果请求币别,则给币别重新赋值
      if (paramObj.BB === 'Y') {
        let bbArr = []
        try {
          bbArr = JSON.parse(data.bbJsonResult)
        } catch (e) {
          console.log('bb arr jsonparse failed---')
          bbArr = []
        }
        let arr = []
        if (bbArr && bbArr.length > 0) {
          for (let i in bbArr) {
            arr[i] = {
              name: bbArr[i]['value'],
              value: bbArr[i]['relationkey']
            }
          }
        }
        store.state.ssc.reimburse.bbOptions = arr
      }
      // 3、如果包含差旅费，则给差旅费孙子表数据合计赋值
      if (data.hasChailv === 'Y') {
        store.state.fybxzb.total_ccf = data.total_ccf // 孙子表的车船费
        store.state.fybxzb.total_clbt = data.total_clbt // 孙子表的差旅补贴费
        store.state.fybxzb.total_czf = data.total_czf // 孙子表的出租车费
        store.state.fybxzb.total_zsf = data.total_zsf // 孙子表的住宿费
      }
    } else {
      store.commit('SetDataSscReimburseRetMsg', data.returnMsg)
    }
    store.state.apiloading--
  }, (data, e) => {
    // paramObj.me.alert('获取出租费数据失败')
    paramObj.me.alert(paramObj.me.getResource('alert.unknown.error') + ':getDataSscReimburseFromMoreTable')
    store.state.apiloading--
  })
}
// 调用166接口，加载未还款金额；
actions.getStaffLoan = function (store, paramObj) {
  store.state.apifinished++
  paramObj.me.httpBpm({
    'employeeNumber': store.state.ssc.reimburse.whBtReimburse.employeeNumber,
    'reimbursecompanycode': store.state.ssc.reimburse.whBtReimburse.reimbursecompanycode,
    'apiName': 'PREXPR@AJAX_Reim_023_EmployeeLoanQuery',
    async: paramObj.async
  }, data => {
    if (data.returnCode === '000000') {
      store.state.retMsg = ''
      store.state.ssc.reimburse.whBtReimburse.unpaidaggregateamount = data.unpaidAmount
      paramObj.me.draftRechargeMoney()
    } else {
      store.state.retMsg = data.retMsg
    }
    paramObj.succfunc && paramObj.succfunc()
    store.state.apifinished--
  }, (data, e) => {
    console.error('error====', e)
    store.state.apifinished--
  })
}
// 费用岗调用166接口，加载未还款金额；
actions.getStaffLoanApproveFee = function (store, paramObj) {
  store.state.apifinished++
  paramObj.me.httpBpm({
    'employeeNumber': store.state.ssc.reimburse.whBtReimburse.employeeNumber,
    'reimbursecompanycode': store.state.ssc.reimburse.whBtReimburse.reimbursecompanycode,
    'apiName': 'PREXPR@AJAX_Reim_023_EmployeeLoanQuery',
    async: paramObj.async
  }, data => {
    if (data.returnCode === '000000') {
      store.state.retMsg = ''
      store.state.ssc.reimburse.whBtReimburseRcmSub.unpaidAggregateAmountFee = data.unpaidAmount
      paramObj.me.reloadRechargeMoney()
    } else {
      store.state.retMsg = data.retMsg
    }
    paramObj.succfunc && paramObj.succfunc()
    store.state.apifinished--
  }, (data, e) => {
    console.error('error====', e)
    store.state.apifinished--
  })
}
export default actions
